\subsection{Open balls}
\begin{definition}
	Let \( M \) be a metric space, \( x \in M \), \( r > 0 \).
	Then the \textit{open ball} in \( M \) of centre \( x \) and radius \( r \) is the set
	\[
		\mathcal D_r(x) = \qty{y \in M \colon d(y,x) < r}
	\]
\end{definition}
The open ball notation is a convenient syntax for denoting closeness in some metric space.
Note that, for example, \( x_n \to n \) in \( M \) is equivalent to saying
\[
	\forall \varepsilon > 0, \exists N \in \mathbb N, \forall n \geq N, x_n \in \mathcal D_\varepsilon(x)
\]
We can also say that \( f \colon M \to M' \) is continuous at \( x \) if
\[
	\forall \varepsilon > 0, \exists \delta > 0, f\qty(\mathcal D_\delta(x)) \subset \mathcal D_\varepsilon(f(x))
\]
\begin{definition}
	The closed ball of centre \( x \) and radius \( r \geq 0 \) is the set
	\[
		\mathcal B_r(x) = \qty{y \in M \colon d(y,x) \leq r}
	\]
\end{definition}
\begin{example}
	In \( \mathbb R \), \( \mathcal D_r(x) = (x-r,x+r) \).
	Further, \( \mathcal B_r(x) = [x-r,x+r] \).
	In the plane \( (\mathbb R^2, d_p) \),
	\[
		\mathcal B_1(0) = \qty{ x \in \mathbb R^2 \colon \norm{x}_p \leq 1 }
	\]
\end{example}
\begin{note}
	\( \mathcal D_r(x) \subset \mathcal B_r(x) \subset \mathcal D_s(x) \) for all \( r < s \).
\end{note}
\begin{example}
	Let \( M \) be a discrete metric space.
	Then for \( x \in M \),
	\[
		\mathcal D_1(x) = \qty{x};\quad \mathcal B_1(x) = M
	\]
\end{example}

\subsection{Neighbourhoods and openness}
\begin{definition}
	Let \( M \) be a metric space, and \( U \subset M \).
	Then for \( x \in M \), we say that \( U \) is a \textit{neighbourhood} of \( x \) (in \( M \)) if
	\[
		\exists r > 0, \mathcal D_r(x) \subset U \iff \exists r > 0, \mathcal B_r(x) \subset U
	\]
\end{definition}
\begin{definition}
	We say \( U \subset M \) is \textit{open} in \( M \), or that \( U \) is an \textit{open subset} of \( M \), if
	\[
		\forall x \in U, \exists r > 0, \mathcal D_r(x) \subset U
	\]
	So \( U \) is a neighbourhood of all points in \( U \).
\end{definition}
\begin{example}
	\( \mathcal D_r(x), \mathcal B_r(x) \) are neighbourhoods of \( x \).
\end{example}
\begin{example}
	Let \( H = \qty{ z \in \mathbb C \colon \Im z \geq 0 } \).
	Let \( w \in H \) and \( \delta = \Im w \).
	If \( \delta > 0 \), then \( \mathcal D_\delta(w) \subset H \).
	If \( \delta = 0 \), then for any \( r \), \( \mathcal D_\delta(w) \not\subset H \).
	So \( H \) is not open.
\end{example}
\begin{lemma}
	Open balls are open.
\end{lemma}
\begin{proof}
	Let \( \mathcal D_r(x) \) be an open ball in a metric space \( M \).
	We need to show that
	\[
		\forall y \in \mathcal D_r(x), \exists \delta > 0, \mathcal D_\delta(y) \subset \mathcal D_r(x)
	\]
	So let \( y \in \mathcal D_r(x) \) and set \( \delta = r - d(x,y) \).
	Note that \( d(x,y) > 0 \), and by the triangle inequality,
	\[
		d(z,x) \leq d(z,y) + d(y,x) < \delta + (r-\delta) = r
	\]
	as required.
\end{proof}
\begin{corollary}
	Let \( M \) be a metric space, \( U \subset M \), \( x \in M \).
	Then \( U \) is a neighbourhood of \( x \) if and only if there exists an open subset \( V \) of \( M \) such that \( x \in V \subset U \).
\end{corollary}
\begin{proof}
	In the forward direction, there exists \( r > 0 \) such that \( \mathcal D_r(x) \subset U \), so let \( V = \mathcal D_r(x) \).
	Conversely, if \( V \) is open we can construct \( r > 0 \) such that \( \mathcal D_r(x) \subset V \subset U \).
	So \( U \) is a neighbourhood of \( x \).
\end{proof}

\subsection{Continuity and convergence using topology}
\begin{proposition}
	In a metric space \( M \), the following are equivalent.
	\begin{enumerate}
		\item \( x_n \to x \);
		\item for all neighbourhoods \( U \) of \( x \) in \( M \), \( \exists N \in \mathbb N, \forall n \geq N, x_n \in U \);
		\item for all open neighbourhoods \( U \) of \( x \) in \( M \), \( \exists N \in \mathbb N, \forall n \geq N, x_n \in U \).
	\end{enumerate}
\end{proposition}
\begin{proof}
	First, (i) implies (ii).
	Let \( U \) be a neighbourhood of \( x \).
	Then by definition \( \exists \varepsilon > 0, \mathcal D_\varepsilon(x) \subset U \).
	Since \( x_n \to x \),
	\[
		\exists N \in \mathbb N, \forall n \geq N, x_n \in \mathcal D_\varepsilon(x)
	\]
	hence \( \forall n \geq N, x_n \in U \).

	Now we show (ii) implies (iii).
	This is clear since any open set \( U \) with \( x \in U \) is a neighbourhood of \( x \).

	Finally, (iii) implies (i).
	Fix \( \varepsilon > 0 \).
	By the above lemma, \( U = \mathcal D_\varepsilon(x) \) is open, and \( x \in U \).
	Then by (iii),
	\[
		\exists N \in \mathbb N, \forall n \geq n, x_n \in U
	\]
	hence \( d(x_n, x) < \varepsilon \).
\end{proof}
\begin{proposition}
	Let \( f \colon M \to M' \) be a function between metric spaces.
	\begin{enumerate}[(a)]
		\item The following are equivalent for all \( x \in M \).
		      \begin{enumerate}[(i)]
			      \item \( f \) is continuous at \( x \);
			      \item for all neighbourhoods \( V \) of \( f(x) \) in \( M' \), there exists a neighbourhood \( U \) of \( x \) in \( M \) such that \( f(U) \subset V \);
			      \item for all neighbourhoods \( V \) of \( f(x) \) in \( M' \), \( f^{-1}(V) \) is a neighbourhood of \( x \) in \( M \).
		      \end{enumerate}
		\item The following are equivalent.
		      \begin{enumerate}[(i)]
			      \item \( f \) is continuous;
			      \item \( f^{-1}(V) \) is open in \( M \) for all open subsets \( V \) of \( M' \).
		      \end{enumerate}
	\end{enumerate}
\end{proposition}
\begin{proof}
	First, we show (a)(i) implies (a)(ii).
	% chktex 36
	Let \( V \) be a neighbourhood of \( f(x) \) in \( M' \).
	By definition, \( \exists \varepsilon > 0 \) such that \( \mathcal D_\varepsilon(f(x)) \subset V \).
	Since \( f \) is continuous at \( x \), there exists \( \delta > 0 \) such that \( f\qty(\mathcal D_\delta(x)) \subset \mathcal D_\varepsilon(f(x)) \).
	Then, \( U = \mathcal D_\delta(x) \) is a neighbourhood of \( x \) in M, and \( f(U) \subset V \).

	Now, (a)(ii) implies (a)(iii).
	% chktex 36
	Let \( V \) be a neighbourhood of \( f(x) \) in \( M' \).
	By (ii), there exists a neighbourhood of \( x \) in \( M \) such that \( f(U) \subset V \).
	Then \( U \subset f^{-1}(V) \) and since \( U \) is a neighbourhood of \( x \) in \( M \), ther exists \( r > 0 \) such that \( \mathcal D_r(x) \subset U \subset f^{-1}(V) \)
	Thus, \( f^{-1}(V) \) is a neighbourhood of \( x \) in \( M \).

	Finally, (a)(iii) implies (a)(i).
	% chktex 36
	Given \( \varepsilon > 0 \), \( V = \mathcal D_\varepsilon(f(x)) \) is a neighbourhood of \( f(x) \) in \( V \).
	By (iii), \( f^{-1}(V) \) is a neighbourhood of \( x \) in \( M \).
	So \( \exists \delta > 0 \) such that \( \mathcal D_\delta(x) \subset f^{-1}(V) \).
	Thus, \( f\qty(\mathcal D_\delta(x)) \subset V = \mathcal D_\varepsilon(f(x)) \).

	Now, (b)(i) implies (b)(ii).
	% chktex 36
	Let \( V \) be open in \( M' \).
	So pick \( x \in f^{-1}(V) \).
	Then, \( f(x) \in V \).
	Since \( V \) is open, \( \exists \varepsilon > 0, \mathcal D_\varepsilon(f(x)) \subset V \).
	Since \( f \) is continuous at \( x \), \( \exists \delta > 0, f\qty(\mathcal D_\delta(x)) \subset \mathcal D_\varepsilon(f(x)) \).
	Then, \( \mathcal D_\delta(x) \subset f^{-1}\qty(\mathcal D_\varepsilon(f(x))) \subset f^{-1}(V) \).

	Finally, (b)(ii) implies (b)(i).
	% chktex 36
	Consider \( x \in M \).
	We must show \( f \) is continuous at \( x \).
	Let \( \varepsilon > 0 \).
	Consider the ball \( V = \mathcal D_\varepsilon(f(x)) \).
	This is open in \( M' \) by the above lemma.
	By (ii), \( f^{-1}(V) \) is open in \( M \).
	Further, \( x \in f^{-1}(V) \).
	So by definition, \( \exists \delta > 0, \mathcal D_\delta(x) \subset V \), which is exactly continuity as required.
\end{proof}

\begin{definition}
	The \textit{topology of a metric space} \( M \) is the family of all open subsets of \( M \).
\end{definition}
\begin{proposition}
	The topology of a metric space satisfies
	\begin{enumerate}
		\item \( \varnothing \) and \( M \) are open;
		\item if \( U_i \) are open in \( M \) for \( i \in I \) (\( I \) may be countable or uncountable), then \( \bigcup_{i \in I} U_i \) is open in \( M \);
		\item if \( U, V \) are open then \( U \cap V \) is open.
	\end{enumerate}
\end{proposition}
\begin{proof}
	(ii): Let \( x \in \bigcup_{i \in I} U_i \), then \( \exists i_a \in I, x \in U_{i_a} \).
	Then since \( U_{i_a} \) is open, \( \exists \delta > 0, \mathcal D_r(x) \subset U_{i_a} \subset \bigcup_{i \in I} U_i \)

	(iii) Given \( x \in U \cap V \), since \( U \) is open then \( \exists r > 0 \), \( \mathcal D_r(x) \subset U \) and \( \exists s > 0 \), \( \mathcal D_s(x) \subset V \).
	Then let \( t = \min(r,s) \), and \( \mathcal D_t(x) = \mathcal D_r(x) \cap \mathcal D_s(x) \subset U \cap V \).
\end{proof}

\subsection{Properties of topology of metric space}
\begin{definition}
	A subspace \( A \) of a metric space \( M \) is \textit{closed in} \( M \) if for every sequence \( (x_n) \in A \) that is convergent in \( M \),
	\[
		\lim_{n \to \infty} x_n \in A
	\]
\end{definition}
\begin{lemma}
	Closed balls are closed.
\end{lemma}
\begin{proof}
	Consider \( \mathcal B_r(x) \) in \( M \).
	Consider further \( (x_n) \in \mathcal B_r(x) \) such that \( x_n \to z \) in \( M \).
	\[
		d(z,x) \leq d(z,x_n) + d(x_n,x) \leq d(z,x_n) + r \to r
	\]
	Hence \( d(z,x) \leq r \), so \( z \in \mathcal B_r(x) \).
\end{proof}
\begin{example}
	\( [0,1] = \mathcal B_{1/2}(1/2) \) is closed in \( \mathbb R \).
	This is not open, for instance consider \( D_r(0) \not\subset [0,1] \).
\end{example}
\begin{example}
	\( (0,1) = \mathcal D_{1/2}(1/2) \) is open in \( \mathbb R \).
	This is not closed, for instance the sequence \( \frac{1}{n+1} \) tends to zero in \( \mathbb R \).
\end{example}
\begin{example}
	\( \mathbb R \) and \( \varnothing \) are open and closed in \( \mathbb R \).
\end{example}
\begin{example}
	\( (0,1] \) in \( \mathbb R \) is neither open nor closed.
	Consider \( \mathcal D_r(1) \not\subset (0,1] \) and \( \frac{1}{n} \to 0 \not\in (0,1] \).
\end{example}
\begin{lemma}
	Let \( A \subset M \).
	Then \( A \) is closed in \( M \) if and only if \( M \setminus A \) is open in \( M \).
\end{lemma}
\begin{proof}
	Let \( A \) be closed.
	Suppose \( M \setminus A \) is not open.
	Then \( \exists x \in M \setminus A, \forall r > 0, \mathcal D_r(x) \not\subset M \setminus A \), so \( \mathcal D_r(x) \cap A \neq \varnothing \).
	In particular, for every \( n \) we can choose a point in \( \mathcal D_{1/n}(x) \cap A \).
	Then, \( d(x_n,x) < \frac{1}{n} \to 0 \) and \( x_n \in A \) which contradicts the fact that \( A \) is closed.

	Conversely, let us assume \( M \setminus A \) is open, but suppose \( A \) is not closed.
	Then there exists a sequence \( (x_n) \in A \) such that \( x_n \to x \) in \( M \) but \( x \not\in A \).
	Since \( x \in M \setminus A \) and \( M \setminus A \) is open, there exists \( \varepsilon > 0, \mathcal D_\varepsilon(x) \subset M \setminus A \).
	Since \( x_n \to x \), we must have \( \exists N \in \mathbb N, \forall n \geq N, x_n \in \mathcal D_\varepsilon(x) \) and hence \( x_n \in M \setminus A \), which is a contradiction.
\end{proof}
\begin{example}
	Let \( M \) be a discrete metric space.
	Let \( A \subset M \).
	Then for all \( x \in A \), \( \mathcal D_1(x) = \qty{x} \subset A \).
	Hence \( A \) is open.
	So in a discrete metric space, all subsets are open.
	Hence every subset is closed.
\end{example}

\subsection{Homeomorphisms}
\begin{definition}
	A map \( f \colon M \to M' \) between metric spaces is called a \textit{homeomorphism} if \( f \) is a bijection and \( f, f^{-1} \) are continuous.
	Equivalently, \( f \) is a bijection, and for all open sets \( V \) in \( M' \), \( f^{-1}(V) \) is open in \( M \), and for all open sets \( U \) in \( M \), \( f(U) \) is open in \( M' \).
	If there exists a homeomorphism between \( M, M' \), we say that \( M, M' \) are homeomorphic.
\end{definition}
\begin{example}
	Consider \( (0,\infty) \) and \( (0,1) \).
	Consider the map \( x \mapsto \frac{1}{x+1} \) with inverse \( x \mapsto \frac{1}{x} - 1 \).
	These are continuous, so the metric spaces are homeomorphic.
\end{example}
\begin{remark}
	Every isometry is a homeomorphism, since it is bijective by definition.
	It is not true that every homeomorphism is an isometry.

	Consider the identity on \( \mathbb R \) with the discrete metric to \( \mathbb R \) with the Euclidean metric.
	This is a continuous bijection whose inverse is not continuous.
	So it is not true that a continuous bijection always has a continuous inverse.
\end{remark}

\subsection{Equivalence of metrics}
\begin{definition}
	Let \( d, d' \) be metrics on a set \( M \).
	We say that \( d, d' \) are \textit{equivalent}, written \( d \sim d' \), if they define the same topology.
	In particular, \( U \subset M \) is open in \( (M,d) \) if and only if \( U \) is open in \( (M,d') \).
	So \( d \sim d' \) if and only if \( \mathrm{id} \colon (M,d) \to (M,d') \) is a homeomorphism.
\end{definition}
\begin{remark}
	If \( d \sim d' \), then \( (M,d) \) and \( (M, d') \) have the same convergent sequences and continuous maps.
\end{remark}
\begin{definition}
	Let \( d, d' \) be metrics on \( M \).
	Then we say \( d, d' \) are \textit{uniformly equivalent}, written \( d \sim_u d' \) if
	\[
		\mathrm{id} \colon (M, d) \to (M, d');\quad \mathrm{id} \colon (M, d') \to (M, d)
	\]
	are uniformly continuous.
	We say \( d, d' \) are \textit{Lipschitz equivalent}, written \( d \sim_\mathrm{Lip} d' \), if the identity maps above are Lipschitz.
	Equivalently, \( d \sim_\mathrm{Lip} d' \) if \( \exists a > 0, b > 0, ad(x,y) \leq d'(x,y) \leq bd(x,y) \).
	Note, \( d \sim_\mathrm{Lip} d' \implies d \sim_u d' \implies d \sim d' \).
\end{definition}
\begin{example}
	Given a metric space \( (M,d) \), we define \( d'(x,y) = \min(1,d(x,y)) \).
	This defines a metric on \( M \), and \( d' \sim_u d \).
\end{example}
\begin{example}
	On \( M \times M' \), \( d_1, d_2, d_\infty \) are pairwise Lipschitz equivalent.
\end{example}
\begin{example}
	Consider \( C[0,1] \).
	The \( L_1 \) metric and the uniform metric are not equivalent.
	Consider \( f_n(x) = x^n \).
	This is convergent to zero in the \( L_1 \) metric but is not convergent in the uniform metric.
\end{example}
\begin{example}
	The discrete metric and Euclidean metric on \( \mathbb R \) are not equivalent.
	This is becaue in the discrete metric all sets are open, but in the Euclidean metric there are some non-open sets.
\end{example}
